package variabilitysmelldetection.measurement.measures.spl;

import java.util.List;

import variabilitysmelldetection.measurement.measures.Measure;
import variabilitysmelldetection.measurement.measures.method.NumberOfMethodRefinements;
import variabilitysmelldetection.measurement.models.ComponentItem;
import variabilitysmelldetection.measurement.models.MethodItem;



public class NumberOfRefinedMethods extends Measure {

	public NumberOfRefinedMethods() {
		super("Number of Refined Methods", "NRM");
	}

	public void measure(List<ComponentItem> items){
		int numOfRefinements = 0;

		for (ComponentItem classe : items) {

			List<MethodItem> methods = classe.getMethods();

			for (MethodItem method : methods) {

				if (!method.isRefinement()) {
					
					Measure measure = method.getMeasure(NumberOfMethodRefinements.class);
					if ((measure != null) && (measure.getValue() > 0)) {
						numOfRefinements++;		
					}
				}
			}
		}
		setValue(numOfRefinements);
	}
}
